package edu.mit.csail.relo.jdt.browse;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.action.IAction;
import org.eclipse.ui.dialogs.SaveAsDialog;

import edu.mit.csail.relo.ReloPlugin;
import edu.mit.csail.relo.ui.ReloAction;

public class SaveReloAction extends ReloAction {

	@Override
	public void run(IAction action) {
		SaveAsDialog dialog = new SaveAsDialog(rc.getViewer().getControl()
				.getShell());
		dialog.setTitle("File name to export as Image");
		dialog.setOriginalName(rc.getDefaultFileName()+".relo");
		// dialog.setFilterExtensions(new String[]{".relo"});
		if (dialog.open() == SaveAsDialog.OK) {
			IPath result = dialog.getResult();
			IFile file = ReloPlugin.getWorkspace().getRoot().getFile(result);
			rc.writeFile(file);
		}
	}
}
